# Maintainer: Christian Rebischke <chris.rebischke@archlinux.org>
pkgname=rosenpass
pkgver=0.1.1
pkgrel=3
pkgdesc="formally verified and post-quantum secure VPN over WireGuard"
url="https://rosenpass.eu"
arch=('loong64' 'x86_64')
license=(MIT APACHE)
makedepends=('cargo' 'git' 'cmake' 'pkg-config' 'rust-bindgen')
depends=('libsodium' 'gawk' 'wireguard-tools' 'findutils')
provides=('rp' 'rosenpass')
source=("${pkgname}-${pkgver}::https://github.com/rosenpass/rosenpass/archive/refs/tags/v${pkgver}.tar.gz")
sha512sums=('73e6c69fbf11707502c50d3c1415a6458976216e3323a154cba2b908e379e2a34f454a3511799d191938c9394795c56197dbe1b8fb64b6a13994bf34e21f9fdc')
b2sums=('7428950b42583f77ca661071e82dd3d590028afe55182aef4e07b0fce54aa6acea57010c5567d83a48e741b04cb592881ef29e04bb6efbdf9291c80ef60d7d45')
options=(!lto)

_bin=rosenpass
_script=rp

prepare() {
    cd "${pkgname}-${pkgver}"
    cargo fetch --locked --target $CARCH-unknown-linux-gnu
}

build() {
    cd "${pkgname}-${pkgver}"
    cargo build --release --frozen
}

check() {
    cd "${pkgname}-${pkgver}"
    cargo test --frozen
}

package() {
    cd "${pkgname}-${pkgver}"
    install -Dm 0755 "target/release/${_bin}" "${pkgdir}/usr/bin/${_bin}"
    install -Dm 0755 "${_script}" "${pkgdir}/usr/bin/${_script}"
    install -Dm 0644 LICENSE-MIT "${pkgdir}/usr/share/licenses/${_pkgname}/LICENSE-MIT"
    install -Dm 0644 LICENSE-APACHE "${pkgdir}/usr/share/licenses/${_pkgname}/LICENSE-APACHE"
}
